/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MonitorPanel.java
 *
 * Created on 08/02/2010, 11:52:40
 */
package org.p2psimulator.gui.panel;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.p2psimulator.analysis.SimulationChart;
import org.p2psimulator.analysis.jfreechart.LineChartBoard;
import org.p2psimulator.engine.SimulationEngine;
import org.p2psimulator.entity.reputation.ReputationRepository;
import org.p2psimulator.exceptions.DatasetFailureException;
import org.p2psimulator.gui.MainScreen;

/**
 *
 * @author Amorim
 */
public class MonitorPanel extends javax.swing.JPanel {

    private SimulationEngine currentEngine;
    private MainScreen mainFrame;

    /** Creates new form MonitorPanel */
    public MonitorPanel() {
        initComponents();
    }

    public void clearCharts() {
        reputationPanel.removeAll();
        reputationPanel.repaint();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        reputationPanel = new javax.swing.JPanel();
        networkPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        scenarioName = new javax.swing.JLabel();
        tick = new javax.swing.JLabel();
        tickTime = new javax.swing.JLabel();
        usedMemory = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        freeMemory = new javax.swing.JLabel();
        totalPeers = new javax.swing.JLabel();
        totalFiles = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        peersOut = new javax.swing.JLabel();
        peersIn = new javax.swing.JLabel();
        sentMessages = new javax.swing.JLabel();
        discardedMessages = new javax.swing.JLabel();
        onlinePeers = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        opinionsNumber = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        protocol = new javax.swing.JLabel();

        reputationPanel.setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout reputationPanelLayout = new javax.swing.GroupLayout(reputationPanel);
        reputationPanel.setLayout(reputationPanelLayout);
        reputationPanelLayout.setHorizontalGroup(
            reputationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        reputationPanelLayout.setVerticalGroup(
            reputationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 263, Short.MAX_VALUE)
        );

        networkPanel.setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout networkPanelLayout = new javax.swing.GroupLayout(networkPanel);
        networkPanel.setLayout(networkPanelLayout);
        networkPanelLayout.setHorizontalGroup(
            networkPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 290, Short.MAX_VALUE)
        );
        networkPanelLayout.setVerticalGroup(
            networkPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 263, Short.MAX_VALUE)
        );

        jPanel1.setBackground(new java.awt.Color(102, 102, 102));

        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Tick:");

        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Scenario:");

        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("Tick Time:");

        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("Memory Usage:");

        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("Peers:");

        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("Files:");

        scenarioName.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        scenarioName.setForeground(new java.awt.Color(204, 204, 0));
        scenarioName.setText("<>");

        tick.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        tick.setForeground(new java.awt.Color(204, 204, 0));
        tick.setText("0");

        tickTime.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        tickTime.setForeground(new java.awt.Color(204, 204, 0));
        tickTime.setText("0");

        usedMemory.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        usedMemory.setForeground(new java.awt.Color(204, 204, 0));
        usedMemory.setText("0");

        jLabel10.setForeground(new java.awt.Color(255, 255, 255));
        jLabel10.setText("Free Memory:");

        freeMemory.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        freeMemory.setForeground(new java.awt.Color(204, 204, 0));
        freeMemory.setText("0");

        totalPeers.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        totalPeers.setForeground(new java.awt.Color(204, 204, 0));
        totalPeers.setText("0");

        totalFiles.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        totalFiles.setForeground(new java.awt.Color(204, 204, 0));
        totalFiles.setText("0");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel10))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(usedMemory, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
                                    .addComponent(freeMemory, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addGap(8, 8, 8)
                                        .addComponent(tick, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jLabel5))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(scenarioName, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel6)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(tickTime, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)
                                        .addGap(1, 1, 1))))))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(totalPeers, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(totalFiles, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(scenarioName)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tickTime)
                    .addComponent(jLabel6)
                    .addComponent(tick)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(usedMemory)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(freeMemory)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(totalFiles)
                    .addComponent(totalPeers)
                    .addComponent(jLabel8))
                .addContainerGap())
        );

        jPanel2.setBackground(new java.awt.Color(102, 102, 102));

        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("Online Peers:");

        jLabel12.setForeground(new java.awt.Color(255, 255, 255));
        jLabel12.setText("Out:");

        jLabel13.setForeground(new java.awt.Color(255, 255, 255));
        jLabel13.setText("In:");

        jLabel14.setForeground(new java.awt.Color(255, 255, 255));
        jLabel14.setText("Sent Messages:");

        jLabel15.setForeground(new java.awt.Color(255, 255, 255));
        jLabel15.setText("Disc. Messages:");

        peersOut.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        peersOut.setForeground(new java.awt.Color(204, 204, 0));
        peersOut.setText("0");

        peersIn.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        peersIn.setForeground(new java.awt.Color(204, 204, 0));
        peersIn.setText("0");

        sentMessages.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        sentMessages.setForeground(new java.awt.Color(204, 204, 0));
        sentMessages.setText("0");

        discardedMessages.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        discardedMessages.setForeground(new java.awt.Color(204, 204, 0));
        discardedMessages.setText("0");

        onlinePeers.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        onlinePeers.setForeground(new java.awt.Color(204, 204, 0));
        onlinePeers.setText("0");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sentMessages, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(18, 18, 18)
                        .addComponent(onlinePeers, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(peersIn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel12)
                        .addGap(18, 18, 18)
                        .addComponent(peersOut, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(discardedMessages, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(19, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(onlinePeers, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(peersIn)
                    .addComponent(jLabel12)
                    .addComponent(peersOut))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(sentMessages, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15)
                    .addComponent(discardedMessages))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBackground(new java.awt.Color(102, 102, 102));

        jLabel16.setForeground(new java.awt.Color(255, 255, 255));
        jLabel16.setText("Opinions:");

        opinionsNumber.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        opinionsNumber.setForeground(new java.awt.Color(204, 204, 0));
        opinionsNumber.setText("0");

        jLabel17.setForeground(new java.awt.Color(255, 255, 255));
        jLabel17.setText("Protocol:");

        protocol.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        protocol.setForeground(new java.awt.Color(204, 204, 0));
        protocol.setText("PROTOCOL");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel17)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(protocol)
                .addGap(30, 30, 30)
                .addComponent(jLabel16)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(opinionsNumber, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(protocol)
                    .addComponent(jLabel16)
                    .addComponent(opinionsNumber))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(11, 11, 11)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(reputationPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(networkPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(networkPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(reputationPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel discardedMessages;
    private javax.swing.JLabel freeMemory;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel networkPanel;
    private javax.swing.JLabel onlinePeers;
    private javax.swing.JLabel opinionsNumber;
    private javax.swing.JLabel peersIn;
    private javax.swing.JLabel peersOut;
    private javax.swing.JLabel protocol;
    private javax.swing.JPanel reputationPanel;
    private javax.swing.JLabel scenarioName;
    private javax.swing.JLabel sentMessages;
    private javax.swing.JLabel tick;
    private javax.swing.JLabel tickTime;
    private javax.swing.JLabel totalFiles;
    private javax.swing.JLabel totalPeers;
    private javax.swing.JLabel usedMemory;
    // End of variables declaration//GEN-END:variables

    public void updateReputationChart(SimulationChart reputationChart) {
        try {
            
            
            LineChartBoard lineChart = new LineChartBoard(reputationChart.getChartName(), reputationChart.getDataset().toJFreeChartDataset(), reputationChart.getXlabel(), reputationChart.getYlabel());
            lineChart.setSize(reputationPanel.getWidth(), reputationPanel.getWidth());
            reputationPanel.removeAll();
            reputationPanel.add(lineChart);
            lineChart.setVisible(true);
            //reputationPanel.repaint();
        } catch (DatasetFailureException ex) {
            Logger.getLogger(MonitorPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void updateNetworkChart(SimulationChart reputationChart) {
        try {
            
            LineChartBoard lineChart = new LineChartBoard(reputationChart.getChartName(), reputationChart.getDataset().toJFreeChartDataset(), reputationChart.getXlabel(), reputationChart.getYlabel());
            lineChart.setSize(networkPanel.getWidth(), networkPanel.getWidth());
            networkPanel.removeAll();
            networkPanel.add(lineChart);
            lineChart.setVisible(true);
            //networkPanel.repaint();
        } catch (DatasetFailureException ex) {
            Logger.getLogger(MonitorPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void updateStatistics() {

        if (currentEngine == null) {
            return;
        }
        int peers = currentEngine.getEnviroment().getGeneralConfig().
                getSimConfig().getTotalPeers();
        double files = currentEngine.getEnviroment().getGeneralConfig().
                getFileConfig().getNumberOfFiles();
        int currentTick = currentEngine.getLastTick();
        double lastTickTime = currentEngine.getLastTickTime();
        int peersInto = currentEngine.getPeersIn();
        int peersOuto = currentEngine.getPeersOut();
        int onlinePeersCnt = currentEngine.getEnviroment().getOverlayNetwork().getOnlinePeers().size();
        String protocolName = currentEngine.getEnviroment().
                getGeneralConfig().getProtocolConfig().getType().name();

        int opinions = 0;
        for (ReputationRepository rep : currentEngine.
                getEnviroment().getReputationManager().getRepositoryMap().values()){
            opinions += rep.getOpinionsNumber();
        }

        long msgCnt = currentEngine.getEnviroment().getNetwork().getMessageCounter();
        long discMsgCnt = currentEngine.getEnviroment().getNetwork().getDiscardedMessageCounter();

        Runtime runtime = Runtime.getRuntime();
        long memoryusage = runtime.totalMemory() - runtime.freeMemory();
        memoryusage = memoryusage/1000000;
        long freememory = runtime.freeMemory();
        freememory = freememory/1000000;

        this.totalPeers.setText("" + peers);
        this.totalFiles.setText("" + files);
        this.tick.setText("" + currentTick);
        this.tickTime.setText("" + lastTickTime);
        this.peersIn.setText("" + peersInto);
        this.peersOut.setText("" + peersOuto);
        this.onlinePeers.setText("" + onlinePeersCnt);
        this.protocol.setText(protocolName);
        this.opinionsNumber.setText("" + opinions);
        this.sentMessages.setText("" + msgCnt);
        this.discardedMessages.setText("" + discMsgCnt);
        this.freeMemory.setText("" + freememory + "MB");
        this.usedMemory.setText("" + memoryusage + "MB");
        this.scenarioName.setText(currentEngine.getEnviroment().getName());
        repaint();
        updateReputationChart(currentEngine.getSimulationLog().getLog().get( "GLOBAL REPUTATION"));
        updateNetworkChart(currentEngine.getEnviroment().getNetwork().getInfoCollector().getTotalMessages());
        
    }

    public SimulationEngine getCurrentEngine() {
        return currentEngine;
    }

    public void setCurrentEngine(SimulationEngine currentEngine) {
        this.currentEngine = currentEngine;
    }

    public MainScreen getMainFrame() {
        return mainFrame;
    }

    public void setMainFrame(MainScreen mainFrame) {
        this.mainFrame = mainFrame;
    }
    
}
